<?php



$start = 0;

$plus = 200;

$end = $start+$plus;


while ($end < 1241548 ) {
 		
	$sql = "SELECT * FROM `domain` WHERE `run` = 0 limit $start ,$end";
	
	$result = $db->Execute($sql);
	$num = $result->RecordCount();
	$mx_res = array();
	if ($num > 0) {
		while (!$result->EOF) {
			getmxrr($result->fields['domain'],$mxhosts,$mxweight);
			$mxhosts = implode('|',$mxhosts);
			if($mxhosts =="") $mxhosts ="false";
			$run=1;
			$id = $result->fields['id'];
			$sql = "UPDATE `lv4`.`domain` SET `mx` = '$mxhosts' , `run` = '$run' WHERE `domain`.`id` = $id;";
			$mx_update[] =  $sql;
			$result->MoveNext();
		}
	}
	
	//db_result($mx_update);
	
	foreach ($mx_update as &$value) {
		$db->Execute($value);
	}
	
	
	 $start = $end;
	echo "<br>";
	echo $end = $start+$plus;
}


exit;

$sql = "SELECT * FROM `domain` WHERE `run` = 0 limit $start ,$end";

$result = $db->Execute($sql);
 $num = $result->RecordCount(); 
 $mx_res = array();
if ($num > 0) {
	while (!$result->EOF) {
		getmxrr($result->fields['domain'],$mxhosts,$mxweight);
		$mxhosts = implode('|',$mxhosts);
		if($mxhosts =="") $mxhosts ="false";
		$run=1;
		$id = $result->fields['id'];
 		$sql = "UPDATE `lv4`.`domain` SET `mx` = '$mxhosts' , `run` = '$run' WHERE `domain`.`id` = $id;";
 		$mx_update[] =  $sql;
		$result->MoveNext();
	}
}

//db_result($mx_update);

foreach ($mx_update as &$value) {
	$db->Execute($value);
}
 





